﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument
{
    class Class2
    {
        public static void Standard29014_3_E5(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            //坐标
            Vector2 v0 = new Vector2(0, 0);
            Vector2 a1 = new Vector2(v0.X + 119.88, v0.Y + 63.01);
            Vector2 a2 = new Vector2(a1.X + 38, a1.Y);
            Vector2 a3 = new Vector2(a1.X, a1.Y - 20);
            Vector2 a4 = new Vector2(a2.X, a3.Y);
            Vector2 a5 = new Vector2(a3.X - 6, a3.Y - 16.44);
            Vector2 v6 = new Vector2(a4.X + 6, a5.Y);
            Vector2 v7 = new Vector2(a5.X, a5.Y - 0.62);
            Vector2 v8 = new Vector2(v6.X, v7.Y);
            Vector2 v9 = new Vector2(v7.X, v7.Y - 1.88);
            Vector2 a10 = new Vector2(v9.X, v9.Y - 4);
            Vector2 a11 = new Vector2(v8.X, a10.Y);
            Vector2 a12 = new Vector2(a10.X + Math.Sin(20 * pi / 180) * 4, a10.Y - Math.Cos(20 * pi / 180) * 4);
            Vector2 a13 = new Vector2(a10.X + Math.Sin(67 * pi / 180) * 5.88, a10.Y - Math.Cos(67 * pi / 180) * 5.88);
            Vector2 a14 = new Vector2(a11.X - Math.Sin(67 * pi / 180) * 5.88, a13.Y);
            Vector2 a15 = new Vector2(a10.X + Math.Sin(84 * pi / 180) * 9, a10.Y - Math.Cos(84 * pi / 180) * 9);
            Vector2 a16 = new Vector2(a11.X - Math.Sin(84 * pi / 180) * 9, a15.Y);
            Vector2 a17 = new Vector2(a10.X + Math.Tan(72 * pi / 180) * 4.5, a10.Y + 4.5);
            Vector2 a18 = new Vector2(a11.X - Math.Tan(72 * pi / 180) * 4.5, a17.Y);
            Vector2 a19 = new Vector2(a1.X + 7, a1.Y);
            Vector2 a20 = new Vector2(a19.X + 5.8, a19.Y);
            Vector2 a21 = new Vector2(a2.X - 7, a2.Y);
            Vector2 a22 = new Vector2(a21.X - 5.8, a21.Y);
            Vector2 a23 = new Vector2(a19.X + 1, a19.Y - 1);
            Vector2 a24 = new Vector2(a20.X + 1, a20.Y - 1);
            Vector2 a25 = new Vector2(a21.X - 1, a21.Y - 1);
            Vector2 a26 = new Vector2(a22.X - 1, a22.Y - 1);
            Vector2 a27 = new Vector2(a24.X, a24.Y - 4.1);
            Vector2 a30 = new Vector2(a26.X, a26.Y - 4.1);
            Vector2 a28 = new Vector2(a27.X + 1.2, a27.Y - 1.2);
            Vector2 a29 = new Vector2(a30.X - 1.2, a30.Y - 1.2);
            Vector2 a31 = new Vector2(a23.X, a23.Y - 14);
            Vector2 a32 = new Vector2(a25.X, a25.Y - 14);
            Vector2 a33 = new Vector2(a32.X, a32.Y - 5);
            Vector2 a34 = new Vector2(a31.X, a31.Y - 5);
            Vector2 a35 = new Vector2(a34.X + 4.5, a34.Y);
            Vector2 a36 = new Vector2(a33.X - 4.5, a33.Y);
            Vector2 a37 = new Vector2(a36.X, a36.Y - 11);
            Vector2 a38 = new Vector2(a35.X, a35.Y - 11);
            Vector2 a39 = new Vector2(a37.X + 2.5, a37.Y);
            Vector2 a40 = new Vector2(a38.X - 2.5, a38.Y);
            Vector2 a41 = new Vector2(a40.X, a40.Y - 7);
            Vector2 a42 = new Vector2(a39.X, a39.Y - 7);
            Vector2 a43 = new Vector2(a41.X - 0.5, a17.Y);
            Vector2 a44 = new Vector2(a42.X + 0.5, a17.Y);


            //图1
            Line line01 = new Line(a1, a3);
            line01.Layer = contour;
            line01.Lineweight = Lineweight.W50;
            dxf.AddEntity(line01);
            Line line02 = new Line(a1, a2);
            line02.Layer = contour;
            line02.Lineweight = Lineweight.W50;
            dxf.AddEntity(line02);
            Line line03 = new Line(a5, v9);
            line03.Layer = contour;
            line03.Lineweight = Lineweight.W50;
            dxf.AddEntity(line03);
            Line line04 = new Line(a12, a15);
            line04.Layer = contour;
            line04.Lineweight = Lineweight.W50;
            dxf.AddEntity(line04);
            Line line05 = new Line(a17, a18);
            line05.Layer = contour;
            line05.Lineweight = Lineweight.W50;
            dxf.AddEntity(line05);
            Line line06 = new Line(a16, a14);
            line06.Layer = contour;
            line06.Lineweight = Lineweight.W50;
            dxf.AddEntity(line06);
            Line line07 = new Line(v6, v8);
            line07.Layer = contour;
            line07.Lineweight = Lineweight.W50;
            dxf.AddEntity(line07);
            Line line08 = new Line(a4, a2);
            line08.Layer = contour;
            line08.Lineweight = Lineweight.W50;
            dxf.AddEntity(line08);
            LwPolyline arc01 = new LwPolyline();
            arc01.Vertexes.Add(new LwPolylineVertex(a5));
            arc01.Vertexes.Add(new LwPolylineVertex(a3));
            arc01.Vertexes[0].Bulge = Math.Tan(45 * pi / 180) / 4;
            arc01.Linetype = Linetype.ByLayer;
            arc01.Lineweight = Lineweight.W50;
            arc01.Layer = contour;
            dxf.AddEntity(arc01);
            Arc arc02 = new Arc(a10, 5.88, 90, -23);
            arc02.Layer = contour;
            arc02.Lineweight = Lineweight.W50;
            dxf.AddEntity(arc02);
            Arc arc03 = new Arc(a10, 4, 90, -70);
            arc03.Layer = contour;
            arc03.Lineweight = Lineweight.W50;
            dxf.AddEntity(arc03);
            LwPolyline arc04 = new LwPolyline();
            arc04.Vertexes.Add(new LwPolylineVertex(a15));
            arc04.Vertexes.Add(new LwPolylineVertex(a17));
            arc04.Vertexes[0].Bulge = Math.Tan(52 * pi / 180) / 4;
            arc04.Linetype = Linetype.ByLayer;
            arc04.Lineweight = Lineweight.W50;
            arc04.Layer = contour;
            dxf.AddEntity(arc04);
            LwPolyline arc05 = new LwPolyline();
            arc05.Vertexes.Add(new LwPolylineVertex(a18));
            arc05.Vertexes.Add(new LwPolylineVertex(a16));
            arc05.Vertexes[0].Bulge = Math.Tan(52 * pi / 180) / 4;
            arc05.Linetype = Linetype.ByLayer;
            arc05.Lineweight = Lineweight.W50;
            arc05.Layer = contour;
            dxf.AddEntity(arc05);
            LwPolyline arc06 = new LwPolyline();
            arc06.Vertexes.Add(new LwPolylineVertex(a4));
            arc06.Vertexes.Add(new LwPolylineVertex(v6));
            arc06.Vertexes[0].Bulge = Math.Tan(45 * pi / 180) / 4;
            arc06.Linetype = Linetype.ByLayer;
            arc06.Lineweight = Lineweight.W50;
            arc06.Layer = contour;
            dxf.AddEntity(arc06);
            Circle circle3 = new Circle(a11, 5.88);
            circle3.Layer = contour;
            circle3.Lineweight = Lineweight.W50;
            dxf.AddEntity(circle3);
            Circle circle4 = new Circle(a11, 2);
            circle4.Layer = contour;
            circle4.Lineweight = Lineweight.W50;
            dxf.AddEntity(circle4);
            Line line09 = new Line(a19, a23);
            line09.Layer = refin;
            line09.Lineweight = Lineweight.W35;
            line09.Linetype = Linetype.DashDot;
            dxf.AddEntity(line09);
            Line line010 = new Line(a20, a24);
            line010.Layer = refin;
            line010.Lineweight = Lineweight.W35;
            line010.Linetype = Linetype.DashDot;
            dxf.AddEntity(line010);
            Line line011 = new Line(a22, a26);
            line011.Layer = refin;
            line011.Lineweight = Lineweight.W35;
            line011.Linetype = Linetype.DashDot;
            dxf.AddEntity(line011);
            Line line012 = new Line(a25, a21);
            line012.Layer = refin;
            line012.Lineweight = Lineweight.W35;
            line012.Linetype = Linetype.DashDot;
            dxf.AddEntity(line012);
            Line line013 = new Line(a23, a34);
            line013.Layer = refin;
            line013.Lineweight = Lineweight.W35;
            line013.Linetype = Linetype.DashDot;
            dxf.AddEntity(line013);
            Line line014 = new Line(a25, a33);
            line014.Layer = refin;
            line014.Lineweight = Lineweight.W35;
            line014.Linetype = Linetype.DashDot;
            dxf.AddEntity(line014);
            Line line015 = new Line(a27, a24);
            line015.Layer = refin;
            line015.Lineweight = Lineweight.W35;
            line015.Linetype = Linetype.DashDot;
            dxf.AddEntity(line015);
            Line line016 = new Line(a26, a30);
            line016.Layer = refin;
            line016.Lineweight = Lineweight.W35;
            line016.Linetype = Linetype.DashDot;
            dxf.AddEntity(line016);
            Line line017 = new Line(a29, a28);
            line017.Layer = refin;
            line017.Lineweight = Lineweight.W35;
            line017.Linetype = Linetype.DashDot;
            dxf.AddEntity(line017);
            Line line018 = new Line(a23, a24);
            line018.Layer = refin;
            line018.Lineweight = Lineweight.W35;
            line018.Linetype = Linetype.DashDot;
            dxf.AddEntity(line018);
            Line line019 = new Line(a25, a26);
            line019.Layer = refin;
            line019.Lineweight = Lineweight.W35;
            line019.Linetype = Linetype.DashDot;
            dxf.AddEntity(line019);
            LwPolyline arc07 = new LwPolyline();
            arc07.Vertexes.Add(new LwPolylineVertex(a27));
            arc07.Vertexes.Add(new LwPolylineVertex(a28));
            arc07.Vertexes[0].Bulge = Math.Tan(45 * pi / 180) / 4;
            arc07.Linetype = Linetype.DashDot;
            arc07.Lineweight = Lineweight.W35;
            arc07.Layer = refin;
            dxf.AddEntity(arc07);
            LwPolyline arc08 = new LwPolyline();
            arc08.Vertexes.Add(new LwPolylineVertex(a29));
            arc08.Vertexes.Add(new LwPolylineVertex(a30));
            arc08.Vertexes[0].Bulge = Math.Tan(45 * pi / 180) / 4;
            arc08.Linetype = Linetype.DashDot;
            arc08.Lineweight = Lineweight.W35;
            arc08.Layer = refin;
            dxf.AddEntity(arc08);
            Line line020 = new Line(a31, a32);
            line020.Layer = refin;
            line020.Lineweight = Lineweight.W35;
            line020.Linetype = Linetype.DashDot;
            dxf.AddEntity(line020);
            Line line021 = new Line(a34, a33);
            line021.Layer = refin;
            line021.Lineweight = Lineweight.W35;
            line021.Linetype = Linetype.DashDot;
            dxf.AddEntity(line021);
            Line line022 = new Line(a40, a39);
            line022.Layer = refin;
            line022.Lineweight = Lineweight.W35;
            line022.Linetype = Linetype.DashDot;
            dxf.AddEntity(line022);
            Line line023 = new Line(a35, a38);
            line023.Layer = refin;
            line023.Lineweight = Lineweight.W35;
            line023.Linetype = Linetype.DashDot;
            dxf.AddEntity(line023);
            Line line024 = new Line(a36, a37);
            line024.Layer = refin;
            line024.Lineweight = Lineweight.W35;
            line024.Linetype = Linetype.DashDot;
            dxf.AddEntity(line024);
            Line line025 = new Line(a40, a41);
            line025.Layer = refin;
            line025.Lineweight = Lineweight.W35;
            line025.Linetype = Linetype.DashDot;
            dxf.AddEntity(line025);
            Line line026 = new Line(a39, a42);
            line026.Layer = refin;
            line026.Lineweight = Lineweight.W35;
            line026.Linetype = Linetype.DashDot;
            dxf.AddEntity(line026);
            Line line027 = new Line(a41, a42);
            line027.Layer = refin;
            line027.Lineweight = Lineweight.W35;
            line027.Linetype = Linetype.DashDot;
            dxf.AddEntity(line027);
            Line line028 = new Line(a41, a43);
            line028.Layer = refin;
            line028.Lineweight = Lineweight.W35;
            line028.Linetype = Linetype.DashDot;
            dxf.AddEntity(line028);
            Line line029 = new Line(a42, a44);
            line029.Layer = refin;
            line029.Lineweight = Lineweight.W35;
            line029.Linetype = Linetype.DashDot;
            dxf.AddEntity(line029);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

    }
}
